<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp" %> 
<title></title>
<style>
.datagrid-body {
height:320px !important;
}
.datagrid-view {
height:350px !important;
}

</style>
<script type="text/javascript">
$(function(){
	
	$('#company').combobox({
		onLoadSuccess : function() {
			var data = $('#company').combobox('getData');
			if (data) {
				$("#company").combobox('select', data[0].userName);
			}
		}
	});
	
	 $("#search").click(function(){
		 var sta = null;
		 if($("#status").combobox("getValue")!=0){
			 sta = $("#status").combobox("getValue");
		 }
			
		var params = {
			customerPhone:$("#customerPhone").val(),
			customerName:$("#customerName").val(),
			recom:$("#recom").val(),
			status:sta,
			endFlag:$("input[type='checkbox']").is(':checked'),
			company:$("#company").combobox("getValue"),
		};
		$("#tt").datagrid("unselectAll");
		$("#tt").datagrid('load',params);
	}); 
	 //导出按钮
	 $("#export").click(function(){
		 var sta = null;
		 if($("#status").combobox("getValue")!=0){
			 sta = $("#status").combobox("getValue");
		 }
		 window.location.href="${ctx}/contract/exportList";/* ?customerPhone="
				 +$("#customerPhone").val()+"&customerName="+$("#customerName").val()
				 +"&recom="+$("#recom").val()+"&status="+sta
				 +"&endFlag="+$("input[type='checkbox']").is(':checked')
				 +"&company="+$("#company").combobox("getValue"); */
	 });
	 $("#add").click(function(){
		 window.location.href="${ctx}/contract/add";
	 });
	 
});

function rowStyle(index,row){
	if (index%2==0){     
        return 'background-color:lightcyan;';     
    }     
}
//鼠标悬停显示提示
function showTips(value, row, index) {
	var content = '';
	if(value != null && value != '' || value == 0){
	    content = '<span title="' + value + '" class="note" >' + value + '</span>';
	}
    return content;
}

//table里面的编辑合同
function formatOper(val,row,index){
	if (val != null && val != "") {
		return '<a href="javascript:audit(\''+row.id+'\');" title="'+val+'&#10;点击查看合同详情">'+val+'</a>';  
	}
}
function audit(id){
	window.location.href="${ctx}/contract/edit?id="+id;
}

function audelete(id){
	window.location.href="${ctx}/contract/deletes?id="+id;
}


//合同状态
function showStatus(value, row, index) {
	var content = '';
	//10：逾期中 20：执行中 30：待二审 40：待一审 50：录入中 60：待放款
	if(value=='10'){
		content = '逾期中'
	}else if(value=='20'){
		content = '执行中'
	}else if(value=='30'){
		content = '待二审'
	}else if(value=='40'){
		content = '待一审'
	}else if(value=='50'){
		content = '录入中'
	}else if(value=='60'){
		content = '待放款'
	}else if(value=='70'){
		content = '已作废'
	}else if(value=='90'){
		content = '已结束'
	}
	return content;
} 
//执行详情
function showXQ(value, row, index) {
	var content;
	if(row.status==10||row.status==20||row.status==90){
		content = '<a href="#">执行详情</a>';
	}else{
		content = '没有生成执行计划，不可以查看执行详细信息';
	}
	return content;  
}
function showEn(value, row, index) {
	var content;
	if(row.status==10){
		content = '<a href="${pageContext.request.contextPath}/contractterminate/contractterminatesetting?id='+row.id+'">强制终了</a>';
	}else{
		content = '没有生成执行计划，不可以强制终了';
	}
	return content;  
}
function showYc(value, row, index) {debugger
	var content;
	if(row.approvalSum!="0"){
		content ='<a href="#">延迟服务费</a>';
	}
	return content;
}
function showUp(value, row, index) {
	var content;
	if(row.status==50){
		content = '<a href="javascript:audit(\''+row.id+'\');" title="'+value+'&#10;点击编辑合同详情">修改</a>';  
	}
	return content;  
}
function showDe(value, row, index) {
	var content;
	if(row.status==50){
		content = '<a href="javascript:audelete(\''+row.id+'\');" title="'+value+'&#10;点击删除合同">删除</a>'
	}
	return content;  
}
</script>
</head>
<body>
<div class="yuqi">
<h3>合同查询</h3>
<div id="tb" style="padding:5px;height:auto">
	<hr/>
	<div>
		<label style="margin-left:0;">客户手机:</label> <input id="customerPhone" class="easyui-textbox" style="width:100px"/>
		<label style="margin-left:0;">客户姓名:</label> <input id="customerName" class="easyui-textbox" style="width:100px"/>
		<label style="margin-left:0;">合同状态:</label>
			<select id="status" name="status" class="easyui-combobox" style="width: 180px;height:26px;" required editable="false" panelHeight="auto">
				<option selected="selected" value="0">全部</option>
				<option value="50">录入中</option>
				<option value="60">待放款</option>
				<option value="70">已作废</option>
				<option value="40">待一审</option>
				<option value="30">待二审</option>
				<option value="20">执行中</option>
				<option value="10">逾期中</option>
				<!-- <option value="90">已结束</option> -->
			</select>
			<label style="margin-left:0;">查看结束合同:</label> <input type="checkbox" name="endFlag"/>
		<label style="margin-left:0;">所属公司:</label> 
			<select id="company" class="easyui-combobox" style="width:100px" mode="remote"
					url="${ctx}/contract/companyCombox"
					valueField="id" textField="orgName" method="get" editable="false"
					panelHeight="auto">
			</select>
		<label style="margin-left:0;">推荐人:</label> <input id="recom" class="easyui-textbox" style="width:100px"/>
		<a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search">查询</a>
		<a id="add" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-add">新增</a>
		<a id="export" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-print">导出</a>
		<hr/>
	</div>
</div>
	<table id="tt" class="easyui-datagrid" 
		url="${ctx }/contract/searchContractList"
		title="" style="width:98%;minWidth:1000px;" 
		rownumbers="true" pagination="true"
		pageList="[10,20,30,40]" method="get"
		toolbar="#tb" singleSelect="true"
		fitColumns="true" idField="id" rowStyler="rowStyle">
		<thead>
			<tr style="background:#148CCA;">
				<th data-options="field:'id',align:'center',formatter:formatOper" style="width:10% ">合同编号</th>
				<th data-options="field:'underCompany',align:'center',formatter:showTips" style="width:10% ">所属公司</th>
				<th data-options="field:'userName',align:'center',formatter:showTips" style="width:10% ">客户姓名</th>
				<th data-options="field:'customerPhone',align:'center',formatter:showTips" style="width:15% ">客户手机</th>
				<th data-options="field:'approvalAmount',align:'center',formatter:showTips" style="width:15% ">产品金额</th>
				<th data-options="field:'appDateStr',align:'center',formatter:showTips" style="width:15% ">销售日期</th>
				<th data-options="field:'approvalCyc',align:'center',formatter:showTips" style="width:8% ">服务期数</th>
				<th data-options="field:'status',align:'center',formatter:showStatus" style="width:8% ">合同状态</th>
				<th data-options="field:'null',align:'center',formatter:showXQ" style="width:9% ">执行详情</th>
				<th data-options="field:'1',align:'center',formatter:showEn" style="width:9% ">强制终了</th>
				<th data-options="field:'2',align:'center',formatter:showYc" style="width:9% ">延迟服务费</th>
				<th data-options="field:'3',align:'center',formatter:showUp" style="width:9% ">修改</th>
				<th data-options="field:'4',align:'center',formatter:showDe" style="width:9% ">删除</th>
			</tr>
		</thead>
	</table>
</div>
</body>
</html>